主题
生成RSA密钥 - GenerateRSAKey
函数简介
生成RSA密钥对,包括公钥和私钥,支持多种格式和密钥大小。
接口名称
GenerateRSAKeyDLL调用
c
int GenerateRSAKey(long instance, string publicKeyPath, string privateKeyPath, int type, int keySize);参数说明
| 参数名 | 类型 | 说明 |
|---|---|---|
| instance | 长整数型 | OLAPlug对象的指针,由 CreateCOLAPlugInterFace 接口生成。 |
| publicKeyPath | 字符串 | 公钥保存路径。 |
| privateKeyPath | 字符串 | 私钥保存路径。 |
| type | 整数型 | 类型:0-生成pem格式秘钥;1-生成xml格式秘钥;2-生成PKCS1格式秘钥。 |
| keySize | 整数型 | 密钥大小:512-512位;1024-1024位;2048-2048位;4096-4096位。 |
示例
SDK 调用
cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
int ret = ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);csharp
using OLAPlug;
var ola = new OLAPlugServer();
int ret = ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);python
from OLAPlugServer import OLAPlugServer
ola = OLAPlugServer()
ret = ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048)java
import com.olaplug.OLAPlugServer;
OLAPlugServer ola = new OLAPlugServer();
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);cpp
var ola = com("OlaPlug.OlaSoft")
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);text
.局部变量 ola, OLAPlug
ola.创建 ()
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);aardio
import OLAPlugServer;
var ola = OLAPlugServer();
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);cpp
#include "OLAPlugServer.h"
OLAPlugServer ola;
ola.GenerateRSAKey("keys/public.pem", "keys/private.pem", 0, 2048);原生 DLL 调用
cpp
long instance = CreateCOLAPlugInterFace();
GenerateRSAKey(instance, "keys/public.pem", "keys/private.pem", 0, 2048);csharp
using System.Runtime.InteropServices;
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long CreateCOLAPlugInterFace();
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GenerateRSAKey(long ola, string publicKeyPath, string privateKeyPath, int type, int keySize);
long instance = CreateCOLAPlugInterFace();
int ret = GenerateRSAKey(instance, "keys/public.pem", "keys/private.pem", 0, 2048);python
long instance = CreateCOLAPlugInterFace();
GenerateRSAKey(instance, "keys/public.pem", "keys/private.pem", 0, 2048);返回值
| 返回值 | 说明 |
|---|---|
| (返回值) | 成功返回0;失败返回其他值。 |
注意事项
| 项目 | 说明 |
|---|---|
| 路径 | 生成的密钥文件将保存到指定的路径。 |
| 使用2048位或更高位数的密钥以保证安全性 | 建议使用2048位或更高位数的密钥以保证安全性。 |
